(function($){

$.fn.tpUploader = function(options){
	//Options and defaults
	options = $.extend({
		formID: "jquery-tpUploader-form",
		formAction: "file-upload",
		fileCount: 1
	}, options);

	//Method
	this.upload = function(){
		$("#" + options.formID).get(0).submit();
	}

	//Initialize
	return this.each(function(){
		var html = '';
		html = html + '<iframe name="jquery-tpUploader-iframe" src="" style="position: absolute; width: 0px; height: 0px; border-style: none;"></iframe>';
		html = html + '<form id="' + options.formID + '" name="' + options.formID + '" action="' + options.formAction + '" method="POST" enctype="multipart/form-data" target="jquery-tpUploader-iframe">';

		for (var i = 0; i < options.fileCount; i++) {
			if (0 != i) {
				html = html + '<br />';
			}

			html = html + '<input name="' + i + '" type="file" class="jquery-tpUploader-file" />';
		}

		html = html + '</form>';
		$(this).html(html);
	});
}

})(jQuery);
